package com.eattravel.config;

import com.eattravel.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.ArrayList;
import java.util.List;

@Configuration  //
public class WebAppConfigurer implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        // /**表示拦截所有的请求
        // excludePathPatterns  过滤那些请求不拦截
        registry.addInterceptor(new LoginInterceptor()).addPathPatterns("/*.html").excludePathPatterns(excludePathes());

    }

    private List<String> excludePathes(){
        List<String> listUrls = new ArrayList<String>();
        listUrls.add("/error/**");

        listUrls.add("/login.html");
        listUrls.add("/register.html");
        //网站静态资源
        listUrls.add("/areashow.html");
     /*   listUrls.add("/comments.html");*/
        listUrls.add("/commodity.html");
        listUrls.add("/footer.html");
        listUrls.add("/head.html");
        listUrls.add("/home.html");
 /*       listUrls.add("/message.html");
        listUrls.add("/mycolle.html");
        listUrls.add("/ordermessage.html");
        listUrls.add("/shopcart.html");*/
        listUrls.add("/storeInfo.html");
        listUrls.add("/storelist.html");
        listUrls.add("/upload.html");

        return listUrls;
    }

}
